Don't fail `cargo run` with bins + examples
authorAlex Crichton <alex@alexcrichton.com>
Sat, 21 Mar 2015 02:30:08 +0000 (19:30 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Sat, 21 Mar 2015 02:30:08 +0000 (19:30 -0700)
If no filter is supplied, then only consider binaries as candidates, not
examples as well.

src/cargo/ops/cargo_run.rs

index 63183c629d8cb79e7c838514206096a5625020f5..787c1e3745857af8c3aeda812eebd65ae50d83d4 100644 (file)
@@ -18,7 +18,10 @@ pub fn run(manifest_path: &Path,
     // will verify that we're buliding at least one binary, so we don't check
     // for that form of existence here.
     let mut bins = root.manifest().targets().iter().filter(|a| {
-        options.filter.matches(a) && !a.is_lib() && !a.is_custom_build()
+        !a.is_lib() && !a.is_custom_build() && match options.filter {
+            CompileFilter::Everything => a.is_bin(),
+            CompileFilter::Only { .. } => options.filter.matches(a),
+        }
     });
     let _ = bins.next();
     if bins.next().is_some() {